<?php
include("../include/db.php");

$_SESSION['rpage'] = $_SERVER['REQUEST_URI']; 
if(!isset($_SESSION[$prefix."_username"])){header("location:../login/");exit;}
if ($_SESSION[$prefix."_security"] < 10){header("location:../login/?error=2"); exit;}

$year = date("Y");


if ($_SERVER['REQUEST_METHOD'] == "POST") {
	$id			= $_POST['id'];
	$name		= $_POST[name];
	$address	= $_POST[address];
	$map		= $_POST[map];
	$delete		= $_POST[delete];

if($delete == "DELETE"){

	//************************ UPDATE USERS ********************************  
	$query = mysql_query("UPDATE screenings SET venue_id = '0' WHERE venue_id = '$id'", $db);
	//********************************************************************** 
	//************************ UPDATE USERS ********************************  
	$query = mysql_query("DELETE FROM venues WHERE venue_id = '$id'", $db);
	//********************************************************************** 

header("Location: venue_list.php?action=deleted"); exit; 
}

//************************ UPDATE USERS ********************************  
$query = mysql_query("UPDATE venues SET venue_name='$name', venue_address='$address', venue_map = '$map' WHERE venue_id = '$id'", $db);
//********************************************************************************* 

header("Location: venue_list.php?action=updated"); exit; 


}//END POST



$in_venue = (int)$_GET['id'];

$result = mysql_query("SELECT * FROM venues WHERE venue_id = '$in_venue'  ", $db);
$myrow = mysql_fetch_array($result, MYSQL_ASSOC)
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="includes/admin.css"/>
<title><?php echo $global_title;?></title>

</head>
<body>

<div id="wrap">
	<div id="page-header">
		<?php include('includes/header.php');?>

	</div>
	
	<div id="page-body">
		<div id="tabs">
			<?php $tab="main"; include('includes/header_tabs.php');?>
		</div>

		<div id="acp">
		<div class="panel">
			<span class="corners-top"><span></span></span>
				<div id="content">
				<div id="menu">
						
					<?php include('includes/menu_top.php');?>	
					<?php include('includes/menu_main.php');?>
					</div>
	
					<div id="main">
<a name="maincontent"></a>


	<h1>Edit Venue</h1>

	<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" >
		<input type="hidden" name="id" value="<?php echo $myrow[venue_id];?>" >
		<fieldset><legend>Edit Venue</legend>

          <dl>
            <dt>Name:</dt>
            <dd><input type="text" name="name" id="name" required autofocus size="50" value="<?php echo $myrow[venue_name];?>"  /></dd>
          </dl>

                    
          <dl>
            <dt>Address:</dt>
            <dd><textarea name="address" rows="6" cols="60" ><?php echo $myrow[venue_address];?></textarea>
                </dd>
          </dl>
          
          <dl>
            <dt>Map Embed Code:</dt>
            <dd><textarea name="map" rows="6" cols="60"><?php echo $myrow[venue_map];?></textarea>
                </dd>
          </dl>
          
          <dl>
            <dt>Delete Venue:</dt>
            <dd><input type="checkbox" name="delete" value="DELETE"></dd>
          </dl>

                   
      <p class="submit-buttons"><input type="submit" class="button1" name="submit" id="submit" value="Update" /></p>
</fieldset>
    </form>	
	
	<?php if($myrow[venue_map] != ''){ ?>
	<h3>Current Map</h3>
	<?php echo $myrow[venue_map];
	} ?>	


    
		</div><!-- main -->
	</div><!-- content -->
<span class="corners-bottom"><span></span></span>
</div><!-- panel -->
</div><!-- acp -->

	
	<div id="page-footer">
	<?php include('includes/footer.php');?>
				</div>
</div><!-- page-body -->
</div><!-- wrap -->

</body> 
</html>